package com.campus.controller;

import com.campus.controller.common.ResponseResult;
import com.campus.dto.*;
import com.campus.model.Teacher;
import com.campus.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping({"/campus/manager"})
public class ManagerController {
    @Autowired
    ManagerService managerService;
    public ManagerController(){}

    /**
     *	Teacher教师管理
     * @return
     */
    @PostMapping("/teacher/add")
    public ResponseResult addTeacher(TeacherDto teacherDto){
        return ResponseResult.ok(managerService.addTeacher(teacherDto));
    }
    @GetMapping("/teacher/id")
    public ResponseResult queryTeacherById(int id){
        return ResponseResult.ok(managerService.queryTeacherById(id));
    }
    @GetMapping("/teacher/name")
    public ResponseResult<List<Teacher>> queryTeacherByName(String name){
        return ResponseResult.ok(managerService.queryTeacherByName(name));
    }

    /**
     * 	Activity活动管理
     * @return
     */
    @PostMapping("/activity/add")
    public ResponseResult addActivity(ActivityDto activityDto){
        return ResponseResult.ok(managerService.addActivity(activityDto));
    }
    @PostMapping("/activity/edit")
    public ResponseResult editActivity(ActivityDto newactivityDto){
        return ResponseResult.ok(managerService.editActivity(newactivityDto));
    }
    @PostMapping("/activity/publish")
    public ResponseResult publishActivity(int activity_id){
        return ResponseResult.ok(managerService.publishActivity(activity_id));
    }
    @GetMapping("/activity/status")
    public ResponseResult queryActivityByStatus(int status){
        return ResponseResult.ok(managerService.queryActivityByStatus(status));
    }
    @GetMapping("/activity/name")
    public ResponseResult queryActivityByName(String name){
        return ResponseResult.ok(managerService.queryActivityByName(name));
    }

    /**
     * 	Class教学班管理
     * @return
     */
    @PostMapping("/class/add")
    public ResponseResult addClass(ClassDto classDto){
        return ResponseResult.ok(managerService.addClass(classDto));
    }
    @PostMapping("/class/modify")
    public ResponseResult modifyClass(ClassDto newclassDto){
        return ResponseResult.ok(managerService.modifyClass(newclassDto));
    }
    //教学班添加学生
    @PostMapping("/class/student")
    public ResponseResult addStudentsToClass(int classId, List<Integer> studentIds){
        return ResponseResult.ok(managerService.addStudentsToClass(classId,studentIds));
    }
    //教学班配置老师(根据教师id)
    @PostMapping("/class/teacher")
    public ResponseResult allocateTeacher(int class_id,int teacher_id){
        return ResponseResult.ok(managerService.allocateTeacher(class_id,teacher_id));
    }


    /**
     * 学员管理
     * @return
     */

    @PostMapping("/student/add")
    public ResponseResult addStudent(StudentDto studentDto){
        return ResponseResult.ok(managerService.addStudent(studentDto));
    }
    @PostMapping("/student/add/excel")
    public ResponseResult addStudentByExcel(String excelPath){
        return ResponseResult.ok(managerService.addStudentByExcel(excelPath));
    }
    @PostMapping("/student/audit")
    public ResponseResult auditStudent(int student_id){
        return ResponseResult.ok(managerService.auditStudent(student_id));
    }
    @PostMapping("/student/audit/excel")
    public ResponseResult auditStudentByExcel(){
        return ResponseResult.ok(managerService.batchAuditStudent());
    }


    /**
     * 	用户管理
     * @return
     */
    @PostMapping("/user/add")
    public ResponseResult addUser(UserDto userDto){
        return ResponseResult.ok(managerService.addUser(userDto));
    }

    @GetMapping("/user/query/name")
    public ResponseResult queryUserByName(String name){
        return ResponseResult.ok(managerService.queryUserByName(name));
    }



}
